/*
 * GoogleCalendarManagerEvoView.java
 */
package googlecalendarmanagerevo;

import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.DateTime;
import com.google.gdata.data.calendar.CalendarEventEntry;
import com.google.gdata.data.extensions.When;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;
import it.illumedellaragione.googlecalendar.Calendario;
import java.net.MalformedURLException;
import java.text.ParseException;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import it.illumedellaragione.googlecalendar.*;
import java.awt.Color;
import java.awt.Event;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * The application's main frame.
 */
public class GoogleCalendarManagerEvoView extends FrameView {

    final String PATH_FILE_CONFIG = "config.properties";
    final String PREFIX_POST_URL_MASTER_CALENDAR = "https://www.google.com/calendar/feeds/";
    final String POSTFIX_POST_URL_MASTER_CALENDAR = "/private/full";
    String POST_URL_MASTER_CALENDAR; 
    final String OWN_CALENDARS = "https://www.google.com/calendar/feeds/default/owncalendars/full";
    final String PREFISSO_CHIAVISTI = "Turni -";
    final String PREFISSO_NOTIFICHE = "Notifiche -";
    final String TITLE_EVENT_TURNO = "Turno Sala Studio";
    final String BOTTONE_CANCELLAZIONE = "Non assegnato";
    final String PREFISSO_BOTTONE_CANCELLAZIONE_TURNO = "Canc ";
    final String PREFISSO_AFFLUENZA = "Affluenza=";
    final int MAXLENGTHCB = 15;
    //FASCIE ORARIE
    final String FASCIA_MATTINA_INIZIO = "09:30";
    final String FASCIA_MATTINA_FINE = "12:30";
    final String FASCIA_POMERIGGIO1_INIZIO = "14:00";
    final String FASCIA_POMERIGGIO1_FINE = "16:30";
    final String FASCIA_POMERIGGIO2_INIZIO = "16:30";
    final String FASCIA_POMERIGGIO2_FINE = "18:30";
    final String FASCIA_IMBRUNIRE_INIZIO = "18:30";
    final String FASCIA_IMBRUNIRE_FINE = "20:30";
    final String FASCIA_SERA_INIZIO = "20:30";
    final String FASCIA_SERA_FINE = "23:00";    
    final Color COLOR_SELECTED = Color.yellow;
    final Color COLOR_NOT_SELECTED = new Color (212,208,200) ;//Color.LIGHT_GRAY; //D4D0C8
    boolean autoconnection = false;
    //Ordine ComboBox per la data
    String[] ordineCBData = {"cbSelectGiorno", "cbSelectMese", "cbSelectAnno"};
    //EVENTI DA MODIFICARE,CANCELLARE
    Calendario chiavistaMattina;
    CalendarEventEntry entryMattina;
    Calendario chiavistaPomeriggio1;
    CalendarEventEntry entryPomeriggio1;
    Calendario chiavistaPomeriggio2;
    CalendarEventEntry entryPomeriggio2;
    Calendario chiavistaImbrunire;
    CalendarEventEntry entryImbrunire;
    Calendario chiavistaSera;
    CalendarEventEntry entrySera;
    //variabili globali
    ManageGoogleCalendar manage;
    CalendarService myService;
    String user = "xxx";
    ArrayList<Calendario> chiavisti;
    String offsetUTC = "+02:00";

    public GoogleCalendarManagerEvoView(SingleFrameApplication app, CalendarService myService, ManageGoogleCalendar manage, String user, String offsetUTC) {
        super(app);

        setLogo();

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
        
        try {

                this.myService = myService;
                this.manage = manage;
                this.user = user;
                this.offsetUTC =offsetUTC;
                POST_URL_MASTER_CALENDAR = PREFIX_POST_URL_MASTER_CALENDAR+user+POSTFIX_POST_URL_MASTER_CALENDAR;
                popolateInterface();

                lblStatus.setText("Connected to Google.");

        } catch (Exception e) {
            e.printStackTrace();            
            this.showErrorDialog(e.getMessage());
        }

    }


    public void popolateInterface() throws AuthenticationException, IOException, ServiceException{            

            resetInterface();

            popolateTurni();

            popolateNotificheRiunioni();

            updateDate();
    }

    private void popolateTurni() throws AuthenticationException, IOException, ServiceException {

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();

        //CalendarService myService = manage.retrieveService(user, pwd);

        chiavisti = manage.getCalendari(myService, PREFISSO_CHIAVISTI);

        //System.out.println("Size "+chiavisti.size());

        //Collections.sort(chiavisti, Chiavista.class);

        int numChiavisti = chiavisti.size();

        for (int i = 0; i < numChiavisti; i++) {

            //cbMattina.addItem(chiavisti.get(i).getName());
            cbMattina.addItem(chiavisti.get(i));
            cbPomeriggio1.addItem(chiavisti.get(i));
            cbPomeriggio2.addItem(chiavisti.get(i));
            cbImbrunire.addItem(chiavisti.get(i));
            cbSera.addItem(chiavisti.get(i));

        }

        //setto il rowcoutn al massimo del num di chiavisti +1 (c'è anche NotSelected)
        //cbMattina.setMaximumRowCount(numChiavisti + 1);
        //cbPomeriggio1.setMaximumRowCount(numChiavisti + 1);
        //cbPomeriggio2.setMaximumRowCount(numChiavisti + 1);
        //cbImbrunire.setMaximumRowCount(numChiavisti + 1);
        //cbSera.setMaximumRowCount(numChiavisti + 1);
        
        cbMattina.setMaximumRowCount(MAXLENGTHCB);
        cbPomeriggio1.setMaximumRowCount(MAXLENGTHCB);
        cbPomeriggio2.setMaximumRowCount(MAXLENGTHCB);
        cbImbrunire.setMaximumRowCount(MAXLENGTHCB);
        cbSera.setMaximumRowCount(MAXLENGTHCB);


        //System.out.print(manage.printPublicAllCalendars(myService));


    }

    private void popolateNotificheRiunioni() throws AuthenticationException, IOException, ServiceException {
        //ManageGoogleCalendar manage = new ManageGoogleCalendar();

        //CalendarService myService = manage.retrieveService(user, pwd);

        ArrayList<Calendario> notifiche = manage.getCalendari(myService, PREFISSO_NOTIFICHE);

        //System.out.println("Size "+chiavisti.size());

        //Collections.sort(chiavisti, Chiavista.class);

        for (int i = 0; i < notifiche.size(); i++) {

            cbRiunioni.addItem(notifiche.get(i));

        }
    }

    private void resetInterface() {
        this.chkInserimentoMaster.setSelected(true);
        this.chkAbilitaAll.setSelected(false);
        this.txtChiavista.setText(PREFISSO_CHIAVISTI + " ");
        empty(cbMattina);
        empty(cbPomeriggio1);
        empty(cbPomeriggio2);
        empty(cbImbrunire);
        empty(cbSera);
        empty(cbRiunioni);

        //nascondo bottoni per cancellazione turni
        resetCancelButtons();

    }

    private void empty(JComboBox cb) {
        //for (int i=0; i<cb.getItemCount(); i++)
        //    if(i!=0)
        //        cb.removeItemAt(i);
        cb.removeAllItems();
        cb.addItem("Not Selected");

    }

    private void setItemsComboBoxGiorniPerMeseCorrente() {

        //System.out.println("Entro");

        int giorno = cbSelectGiorno.getSelectedIndex();
        int ultimoGiorno = cbSelectGiorno.getItemCount();
        int mese = cbSelectMese.getSelectedIndex();
        int anno = cbSelectAnno.getSelectedIndex() + Integer.parseInt(cbSelectAnno.getItemAt(0).toString().trim());

        //this.cbSelectGiorno.removeAllItems();

        int giorniNelMeseCorrente = daysInMonth(mese, anno);
        //console.append("Giorni: "+giorniNelMeseCorrente+ "     Mese: "+mese +"    Anno:"+anno);

        int differenzaTotGiorni = giorniNelMeseCorrente - ultimoGiorno;

        for (int k = 0; k < differenzaTotGiorni * Integer.signum(differenzaTotGiorni); k++) {
            if (differenzaTotGiorni > 0) {
                cbSelectGiorno.addItem("" + (ultimoGiorno + k + 1));
            } else if (differenzaTotGiorni < 0) {
                cbSelectGiorno.removeItemAt(cbSelectGiorno.getItemCount() - 1);
            }
        }

    }

    private void resetCancelButtons() {
        //nascondo bottoni per cancellazione turni
        btCancellaTurnoMattina.setBackground(COLOR_NOT_SELECTED);
        btCancellaTurnoMattina.setText(BOTTONE_CANCELLAZIONE);
        //btCancellaTurnoMattina.setVisible(false);
        btCancellaTurnoPomeriggio1.setBackground(COLOR_NOT_SELECTED);
        btCancellaTurnoPomeriggio1.setText(BOTTONE_CANCELLAZIONE);
        //btCancellaTurnoPomeriggio1.setVisible(false);
        btCancellaTurnoPomeriggio2.setBackground(COLOR_NOT_SELECTED);
        btCancellaTurnoPomeriggio2.setText(BOTTONE_CANCELLAZIONE);
        //btCancellaTurnoPomeriggio2.setVisible(false);
        btCancellaTurnoImbrunire.setBackground(COLOR_NOT_SELECTED);
        btCancellaTurnoImbrunire.setText(BOTTONE_CANCELLAZIONE);
        //btCancellaTurnoImbrunire.setVisible(false);
        btCancellaTurnoSera.setBackground(COLOR_NOT_SELECTED);
        btCancellaTurnoSera.setText(BOTTONE_CANCELLAZIONE);
        //btCancellaTurnoSera.setVisible(false);
    }

    
    private void updateDate() {
        GregorianCalendar cal = new GregorianCalendar();

        cbSelectGiorno.setSelectedIndex(cal.get(Calendar.DATE) - 1);
        cbSelectMese.setSelectedIndex(cal.get(Calendar.MONTH));
        cbSelectAnno.setSelectedIndex(cal.get(Calendar.YEAR) - Integer.parseInt(cbSelectAnno.getSelectedItem().toString().trim()));

        cbSelectGiornoRiunione.setSelectedIndex(cal.get(Calendar.DATE) - 1);
        cbSelectMeseRiunione.setSelectedIndex(cal.get(Calendar.MONTH));
        cbSelectAnnoRiunione.setSelectedIndex(cal.get(Calendar.YEAR) - Integer.parseInt(cbSelectAnnoRiunione.getSelectedItem().toString().trim()));

    }

    public static int daysInMonth(GregorianCalendar c) {
        int[] daysInMonths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        daysInMonths[1] += c.isLeapYear(c.get(GregorianCalendar.YEAR)) ? 1 : 0;
        return daysInMonths[c.get(GregorianCalendar.MONTH)];
    }

    public static int daysInMonth(int month, int year) {
        GregorianCalendar c = new GregorianCalendar();
        int[] daysInMonths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        daysInMonths[1] += c.isLeapYear(year) ? 1 : 0;
        return daysInMonths[month];
    }

    private void resetTurni() {
        //sbiancare tutti i campi dei turni


        cbMattina.setSelectedIndex(0);
        cbPomeriggio1.setSelectedIndex(0);
        cbPomeriggio2.setSelectedIndex(0);
        cbImbrunire.setSelectedIndex(0);
        cbSera.setSelectedIndex(0);
        console.setText("");

    }

    private void disableUselessBox() {

        int date = Integer.parseInt(this.cbSelectGiorno.getSelectedItem().toString());
        int month = cbSelectMese.getSelectedIndex();
        int year = Integer.parseInt(this.cbSelectAnno.getSelectedItem().toString());//;Integer.parseInt(.getItemAt(cbSelectAnno.getSelectedIndex()).toString());

        GregorianCalendar ogg = new GregorianCalendar(year, month, date);

        //console.setText(ogg.getTime().toString()+console.getText());
        //System.out.println("Questo giorno"+ogg.get(Calendar.DAY_OF_WEEK));
        int day = ogg.get(Calendar.DAY_OF_WEEK);

        String Name = null;
        if (day == 1) {
            Name = "Domenica";
            cbMattina.setEnabled(false);
            cbPomeriggio1.setEnabled(false);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(false);
            cbSera.setEnabled(false);
        } else if (day == 2) {
            Name = "Lunedì";
            cbMattina.setEnabled(true);
            cbPomeriggio1.setEnabled(true);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(true);
            cbSera.setEnabled(true);
        } else if (day == 3) {
            Name = "Martedì";
            cbMattina.setEnabled(false);
            cbPomeriggio1.setEnabled(false);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(true);
            cbSera.setEnabled(true);
        } else if (day == 4) {
            Name = "Mercoledì";
            cbMattina.setEnabled(true);
            cbPomeriggio1.setEnabled(false);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(true);
            cbSera.setEnabled(true);
        } else if (day == 5) {
            Name = "Giovedì";
            cbMattina.setEnabled(false);
            cbPomeriggio1.setEnabled(false);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(true);
            cbSera.setEnabled(true);
        } else if (day == 6) {
            Name = "Venerdì";
            cbMattina.setEnabled(false);
            cbPomeriggio1.setEnabled(false);
            cbPomeriggio2.setEnabled(false);
            cbImbrunire.setEnabled(false);
            cbSera.setEnabled(false);
        } else if (day == 7) {
            Name = "Sabato";
            cbMattina.setEnabled(false);
            cbPomeriggio1.setEnabled(true);
            cbPomeriggio2.setEnabled(true);
            cbImbrunire.setEnabled(false);
            cbSera.setEnabled(false);
        }
        jlGiorno.setText(Name);

    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = GoogleCalendarManagerEvoApp.getApplication().getMainFrame();
            aboutBox = new GoogleCalendarManagerEvoAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        GoogleCalendarManagerEvoApp.getApplication().show(aboutBox);
    }

    @Action
    public void showOptionsDialog() {
        if (optionsDialog == null) {
            //JFrame mainFrame = GoogleCalendarManagerEvoApp.getApplication().getMainFrame();
            FrameView mainFrame = this;
            optionsDialog = new GoogleCalendarManagerEvoOptionsDialog(mainFrame.getFrame(), true);
            optionsDialog.setLocationRelativeTo(mainFrame.getFrame());
        }
        GoogleCalendarManagerEvoApp.getApplication().show(optionsDialog);
    }

    private void showErrorDialog(String str){
            //custom title, error icon
            JOptionPane.showMessageDialog(this.getFrame(),
            str,
            "Error",
            JOptionPane.ERROR_MESSAGE);
            setStatus("Errore: " + str);
    }

    private void setStatus(String str){
        lblStatus.setText(str);
    }

    private String getStatus(){
        return lblStatus.getText();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        cbSelectGiorno = new javax.swing.JComboBox();
        cbSelectMese = new javax.swing.JComboBox();
        cbSelectAnno = new javax.swing.JComboBox();
        jlGiorno = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        cbMattina = new javax.swing.JComboBox();
        cbPomeriggio2 = new javax.swing.JComboBox();
        cbPomeriggio1 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cbSera = new javax.swing.JComboBox();
        cbImbrunire = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        console = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        chkInserimentoMaster = new javax.swing.JCheckBox();
        chkAbilitaAll = new javax.swing.JCheckBox();
        btCancellaTurnoSera = new javax.swing.JButton();
        btCancellaTurnoMattina = new javax.swing.JButton();
        btCancellaTurnoPomeriggio1 = new javax.swing.JButton();
        btCancellaTurnoImbrunire = new javax.swing.JButton();
        btCancellaTurnoPomeriggio2 = new javax.swing.JButton();
        buttonPlusDay = new javax.swing.JButton();
        buttonMinusDay = new javax.swing.JButton();
        chkBomb = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtChiavista = new javax.swing.JTextField();
        buttonCreaChiavista = new javax.swing.JButton();
        buttonCancellaChiavista = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        cbRiunioni = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        cbSelectGiornoRiunione = new javax.swing.JComboBox();
        cbSelectMeseRiunione = new javax.swing.JComboBox();
        cbSelectAnnoRiunione = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        txtOraInizioEvento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtOraFineEvento = new javax.swing.JTextField();
        jButtonCreaEvento = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtTitoloEvento = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtDescrizioneEvento = new javax.swing.JTextArea();
        lblGiornoRiunione = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        jMenuTools = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        lblStatus = new javax.swing.JLabel();

        mainPanel.setName("mainPanel"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        cbSelectGiorno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cbSelectGiorno.setName("cbSelectGiorno"); // NOI18N
        cbSelectGiorno.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectGiornoItemStateChanged(evt);
            }
        });

        cbSelectMese.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" }));
        cbSelectMese.setName("cbSelectMese"); // NOI18N
        cbSelectMese.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectMesecbSelectGiornoItemStateChanged(evt);
            }
        });

        cbSelectAnno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));
        cbSelectAnno.setName("cbSelectAnno"); // NOI18N
        cbSelectAnno.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectAnnocbSelectGiornoItemStateChanged(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(googlecalendarmanagerevo.GoogleCalendarManagerEvoApp.class).getContext().getResourceMap(GoogleCalendarManagerEvoView.class);
        jlGiorno.setText(resourceMap.getString("jlGiorno.text")); // NOI18N
        jlGiorno.setName("jlGiorno"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        cbMattina.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbMattina.setName("cbMattina"); // NOI18N

        cbPomeriggio2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbPomeriggio2.setName("cbPomeriggio2"); // NOI18N

        cbPomeriggio1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbPomeriggio1.setName("cbPomeriggio1"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        cbSera.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbSera.setName("cbSera"); // NOI18N

        cbImbrunire.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbImbrunire.setName("cbImbrunire"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        console.setColumns(20);
        console.setRows(5);
        console.setName("console"); // NOI18N
        console.setLineWrap(true);
        jScrollPane1.setViewportView(console);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(googlecalendarmanagerevo.GoogleCalendarManagerEvoApp.class).getContext().getActionMap(GoogleCalendarManagerEvoView.class, this);
        jButton1.setAction(actionMap.get("invia")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                invia(evt);
            }
        });

        chkInserimentoMaster.setText(resourceMap.getString("chkInserimentoMaster.text")); // NOI18N
        chkInserimentoMaster.setName("chkInserimentoMaster"); // NOI18N

        chkAbilitaAll.setText(resourceMap.getString("chkAbilitaAll.text")); // NOI18N
        chkAbilitaAll.setName("chkAbilitaAll"); // NOI18N
        chkAbilitaAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkAbilitaAllActionPerformed(evt);
            }
        });

        btCancellaTurnoSera.setText(resourceMap.getString("btCancellaTurnoSera.text")); // NOI18N
        btCancellaTurnoSera.setName("btCancellaTurnoSera"); // NOI18N
        btCancellaTurnoSera.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancellaTurnoSeraActionPerformed(evt);
            }
        });

        btCancellaTurnoMattina.setText(resourceMap.getString("btCancellaTurnoMattina.text")); // NOI18N
        btCancellaTurnoMattina.setName("btCancellaTurnoMattina"); // NOI18N
        btCancellaTurnoMattina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancellaTurnoMattinaActionPerformed(evt);
            }
        });

        btCancellaTurnoPomeriggio1.setText(resourceMap.getString("btCancellaTurnoPomeriggio1.text")); // NOI18N
        btCancellaTurnoPomeriggio1.setName("btCancellaTurnoPomeriggio1"); // NOI18N
        btCancellaTurnoPomeriggio1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancellaTurnoPomeriggio1ActionPerformed(evt);
            }
        });

        btCancellaTurnoImbrunire.setText(resourceMap.getString("btCancellaTurnoImbrunire.text")); // NOI18N
        btCancellaTurnoImbrunire.setName("btCancellaTurnoImbrunire"); // NOI18N
        btCancellaTurnoImbrunire.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancellaTurnoImbrunireActionPerformed(evt);
            }
        });

        btCancellaTurnoPomeriggio2.setText(resourceMap.getString("btCancellaTurnoPomeriggio2.text")); // NOI18N
        btCancellaTurnoPomeriggio2.setName("btCancellaTurnoPomeriggio2"); // NOI18N
        btCancellaTurnoPomeriggio2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancellaTurnoPomeriggio2ActionPerformed(evt);
            }
        });

        buttonPlusDay.setAction(actionMap.get("buttonPlusDayPressed")); // NOI18N
        buttonPlusDay.setText(resourceMap.getString("jButtonPlusDay.text")); // NOI18N
        buttonPlusDay.setName("jButtonPlusDay"); // NOI18N

        buttonMinusDay.setAction(actionMap.get("buttonMinusDayPressed")); // NOI18N
        buttonMinusDay.setText(resourceMap.getString("jButtonMinusDay.text")); // NOI18N
        buttonMinusDay.setName("jButtonMinusDay"); // NOI18N

        chkBomb.setText(resourceMap.getString("chkBomb.text")); // NOI18N
        chkBomb.setName("chkBomb"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 767, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5))
                                .addGap(22, 22, 22)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbSera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(cbPomeriggio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(cbPomeriggio2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(cbMattina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbImbrunire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(30, 30, 30)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(btCancellaTurnoSera)
                                            .addComponent(btCancellaTurnoMattina)
                                            .addComponent(btCancellaTurnoPomeriggio1))
                                        .addGap(18, 18, 18)
                                        .addComponent(btCancellaTurnoPomeriggio2)
                                        .addGap(84, 84, 84)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(chkInserimentoMaster)
                                            .addComponent(chkAbilitaAll)
                                            .addComponent(chkBomb)))
                                    .addComponent(btCancellaTurnoImbrunire))
                                .addGap(88, 88, 88)))
                        .addGap(125, 125, 125))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(buttonPlusDay)
                        .addGap(7, 7, 7)
                        .addComponent(buttonMinusDay, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cbSelectGiorno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cbSelectMese, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cbSelectAnno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addComponent(jlGiorno)
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonPlusDay)
                    .addComponent(buttonMinusDay)
                    .addComponent(cbSelectGiorno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSelectMese, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSelectAnno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jlGiorno))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbMattina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(chkAbilitaAll)
                    .addComponent(btCancellaTurnoMattina))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbPomeriggio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(cbPomeriggio2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(chkInserimentoMaster)
                    .addComponent(btCancellaTurnoPomeriggio1)
                    .addComponent(btCancellaTurnoPomeriggio2))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cbImbrunire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btCancellaTurnoImbrunire)
                    .addComponent(chkBomb))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(cbSera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btCancellaTurnoSera)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        buttonPlusDay.getAccessibleContext().setAccessibleName(resourceMap.getString("jButtonPlusDay.AccessibleContext.accessibleName")); // NOI18N
        buttonMinusDay.getAccessibleContext().setAccessibleName(resourceMap.getString("jButton3.AccessibleContext.accessibleName")); // NOI18N

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txtChiavista.setText(resourceMap.getString("txtChiavista.text")); // NOI18N
        txtChiavista.setName("txtChiavista"); // NOI18N

        buttonCreaChiavista.setAction(actionMap.get("creaChiavista")); // NOI18N
        buttonCreaChiavista.setText(resourceMap.getString("buttonCreaChiavista.text")); // NOI18N
        buttonCreaChiavista.setName("buttonCreaChiavista"); // NOI18N

        buttonCancellaChiavista.setAction(actionMap.get("deleteCalendarChiavista")); // NOI18N
        buttonCancellaChiavista.setText(resourceMap.getString("buttonCancellaChiavista.text")); // NOI18N
        buttonCancellaChiavista.setName("buttonCancellaChiavista"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                        .addComponent(txtChiavista, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(buttonCreaChiavista)
                        .addGap(18, 18, 18)
                        .addComponent(buttonCancellaChiavista)))
                .addGap(245, 245, 245))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtChiavista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonCreaChiavista)
                    .addComponent(buttonCancellaChiavista))
                .addContainerGap(273, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        cbRiunioni.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Not Selected" }));
        cbRiunioni.setName("cbRiunioni"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        cbSelectGiornoRiunione.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cbSelectGiornoRiunione.setName("cbSelectGiornoRiunione"); // NOI18N
        cbSelectGiornoRiunione.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectGiornoRiunioneItemStateChanged(evt);
            }
        });

        cbSelectMeseRiunione.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" }));
        cbSelectMeseRiunione.setName("cbSelectMeseRiunione"); // NOI18N
        cbSelectMeseRiunione.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectMeseRiunionecbSelectGiornoItemStateChanged(evt);
            }
        });

        cbSelectAnnoRiunione.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));
        cbSelectAnnoRiunione.setName("cbSelectAnnoRiunione"); // NOI18N
        cbSelectAnnoRiunione.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSelectAnnoRiunionecbSelectGiornoItemStateChanged(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        txtOraInizioEvento.setText(resourceMap.getString("txtOraInizioEvento.text")); // NOI18N
        txtOraInizioEvento.setName("txtOraInizioEvento"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        txtOraFineEvento.setText(resourceMap.getString("txtOraFineEvento.text")); // NOI18N
        txtOraFineEvento.setName("txtOraFineEvento"); // NOI18N

        jButtonCreaEvento.setAction(actionMap.get("creaRiunione")); // NOI18N
        jButtonCreaEvento.setText(resourceMap.getString("jButtonCreaEvento.text")); // NOI18N
        jButtonCreaEvento.setName("jButtonCreaEvento"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        txtTitoloEvento.setText(resourceMap.getString("txtTitoloEvento.text")); // NOI18N
        txtTitoloEvento.setName("txtTitoloEvento"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        txtDescrizioneEvento.setColumns(20);
        txtDescrizioneEvento.setRows(5);
        txtDescrizioneEvento.setName("txtDescrizioneEvento"); // NOI18N
        jScrollPane2.setViewportView(txtDescrizioneEvento);

        lblGiornoRiunione.setText(resourceMap.getString("lblGiornoRiunione.text")); // NOI18N
        lblGiornoRiunione.setName("lblGiornoRiunione"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButtonCreaEvento)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7)
                                .addComponent(jLabel8)
                                .addComponent(jLabel9))
                            .addGap(27, 27, 27)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtOraFineEvento)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(cbSelectGiornoRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(cbSelectMeseRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(cbSelectAnnoRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(lblGiornoRiunione))
                                .addComponent(cbRiunioni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtOraInizioEvento)
                                .addComponent(txtTitoloEvento)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 544, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addContainerGap(228, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(cbRiunioni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(cbSelectGiornoRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSelectMeseRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSelectAnnoRiunione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblGiornoRiunione))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtOraInizioEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtOraFineEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txtTitoloEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(jButtonCreaEvento)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 907, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        jMenuTools.setText(resourceMap.getString("jMenuTools.text")); // NOI18N
        jMenuTools.setName("jMenuTools"); // NOI18N

        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenuTools.add(jMenuItem1);

        jMenuItem2.setAction(actionMap.get("showOptionsDialog")); // NOI18N
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuTools.add(jMenuItem2);

        menuBar.add(jMenuTools);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        lblStatus.setText(resourceMap.getString("lblStatus.text")); // NOI18N
        lblStatus.setName("lblStatus"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 917, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(statusMessageLabel)
                    .addComponent(lblStatus))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 743, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel)
                            .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(3, 3, 3))
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblStatus)
                        .addContainerGap())))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void cbSelectGiornoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectGiornoItemStateChanged
        resetTurni();
        disableUselessBox();
        try {
            //System.out.println("1");
            resetCancelButtons();
            getChiavistiDelGiorno();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }//GEN-LAST:event_cbSelectGiornoItemStateChanged

    private void cbSelectMesecbSelectGiornoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectMesecbSelectGiornoItemStateChanged
        resetTurni();
        setItemsComboBoxGiorniPerMeseCorrente();
        disableUselessBox();
        try {
            //System.out.println("2");
            resetCancelButtons();
            getChiavistiDelGiorno();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_cbSelectMesecbSelectGiornoItemStateChanged

    private void cbSelectAnnocbSelectGiornoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectAnnocbSelectGiornoItemStateChanged
        resetTurni();
        setItemsComboBoxGiorniPerMeseCorrente();
        disableUselessBox();
        try {
            //System.out.println("3");
            resetCancelButtons();
            getChiavistiDelGiorno();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_cbSelectAnnocbSelectGiornoItemStateChanged

    @Action
    public void buttonPlusDayPressed() {

        changeDay(1, true);

    }

    @Action
    public void buttonMinusDayPressed() {
        //console.append("-");

        changeDay(1, false);

    }

    //metodo che calcola il prossimo giorno o il precedente
    //level (1: giorno, 2:mese, 3:anno)
    //argomento booleano plus
    //true: aggiungi 1 giorno
    //false: togli 1 giorno
    private void changeDay(int level, boolean plus) {

        //piede della ricorsione se arrivo fino in fondo
        if (level >= 4) {
            return; //ho sforato il livello
        }
        JComboBox cb = getComboBox(level);

        int index = cb.getSelectedIndex();
        int nextIndex = (plus ? index + 1 : index - 1);
        int maxIndex = cb.getItemCount() - 1;
        int minIndex = 0;

        if (plus && nextIndex > maxIndex) {
            changeDay(level + 1, plus);
            cb.setSelectedIndex(0);
        } else if (!plus && nextIndex < 0) {
            changeDay(level + 1, plus);
            if (level == 1) {
                maxIndex = cb.getItemCount() - 1;
            }
            cb.setSelectedIndex(maxIndex);
        } else {
            cb.setSelectedIndex(nextIndex);
        }

    }

    private JComboBox getComboBox(int level) {
        if (level == 1) {
            return this.cbSelectGiorno;
        }
        if (level == 2) {
            return this.cbSelectMese;
        }
        if (level == 3) {
            return this.cbSelectAnno;
        }
        return null;
    }



    private void chkAbilitaAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAbilitaAllActionPerformed

        if (chkAbilitaAll.isSelected()) {
            cbMattina.setEnabled(true);
            cbPomeriggio1.setEnabled(true);
            cbPomeriggio2.setEnabled(true);
            cbImbrunire.setEnabled(true);
            cbSera.setEnabled(true);
        } else {
            resetTurni();
            disableUselessBox();
        }
}//GEN-LAST:event_chkAbilitaAllActionPerformed

    private void getChiavistiDelGiorno() throws AuthenticationException, MalformedURLException, IOException, ServiceException, ParseException {

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();
        //CalendarService myService = manage.retrieveService(user, pwd);

        String pattern = TITLE_EVENT_TURNO;

        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String giorno = cbSelectGiorno.getSelectedItem().toString().trim();
        String mese = "" + (cbSelectMese.getSelectedIndex() + 1);
        String anno = cbSelectAnno.getSelectedItem().toString().trim();

        Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_MATTINA_INIZIO + ":00");
        Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_SERA_FINE + ":00");
        String dataInizioString = (dfm.format(dataInizio)).replace(' ', 'T');
        String dataFineString = (dfm.format(dataFine)).replace(' ', 'T');
        DateTime startTime = DateTime.parseDateTime(dataInizioString);
        DateTime endTime = DateTime.parseDateTime(dataFineString);

        //System.out.println("startDate: "+startTime);

        //PRENDO TUTTI GLI EVENTI DEL GIORNO DAL CALENDARIO MASTER E LI GESTISCO
        List<CalendarEventEntry> events = manage.getEventi(myService, POST_URL_MASTER_CALENDAR, startTime, endTime);

        this.resetCancelButtons();
        
        for (int i = 0; i < events.size(); i++) {
            CalendarEventEntry entry = events.get(i);
            //se il titolo contiene il pattern, gestisco su che fascia orario è
            if (entry.getTitle().getPlainText().trim().contains(pattern)) {

                //System.out.println("Turno: " + entry.getTitle().getPlainText().trim().replace(pattern, ""));//+ " Dalle: "+entry.getTimes().get(0).toString() +"  Alle: "+entry.getTimes().get(1).toString());
                Calendario chiavista = getChiavistaCorrente(entry.getTitle().getPlainText().trim().replace(pattern, "").trim());

                //è un turno getisco il bottone di cancellazione
                List<When> whens = entry.getTimes();
                //System.out.println("start = " + whens.get(0).getStartTime());
                //System.out.println("start = " + whens.get(0).getStartTime().toUiString()); //toUiString "yyyy-MM-dd hh:ss"
                //prendo solo il primo when (dovrebbe solo esserci un valore per turno, non ci sono turni ripetuti)
                try {
                    String inizioEntryCorrente = whens.get(0).getStartTime().toUiString(); //toUiString "yyyy-MM-dd hh:ss"
                    //tolgo la data e confronto con le fascie orarie
                    String oraInizioEntryCorrente = inizioEntryCorrente.substring(inizioEntryCorrente.length() - 5).trim();
                    //System.out.println("oraInizioEntryCorrente = " + oraInizioEntryCorrente);
                    //CHECK FASCIA ORARIA

                    //MATTINA
                    if (oraInizioEntryCorrente.equalsIgnoreCase(FASCIA_MATTINA_INIZIO)) {
                        entryMattina = entry;
                        chiavistaMattina = chiavista;
                        btCancellaTurnoMattina.setVisible(true);
                        btCancellaTurnoMattina.setBackground(COLOR_SELECTED);
                        btCancellaTurnoMattina.setText(PREFISSO_BOTTONE_CANCELLAZIONE_TURNO + chiavista.getName().trim());
                        //reset combobox chiavista associata
                        cbMattina.setSelectedIndex(0);
                        cbMattina.setEnabled(false);
                    }

                    //POMERIGGIO1
                    if (oraInizioEntryCorrente.equalsIgnoreCase(FASCIA_POMERIGGIO1_INIZIO)) {
                        entryPomeriggio1 = entry;
                        chiavistaPomeriggio1 = chiavista;
                        btCancellaTurnoPomeriggio1.setVisible(true);
                        btCancellaTurnoPomeriggio1.setBackground(COLOR_SELECTED);
                        btCancellaTurnoPomeriggio1.setText(PREFISSO_BOTTONE_CANCELLAZIONE_TURNO + chiavista.getName().trim());
                        //reset combobox chiavista associata
                        cbPomeriggio1.setSelectedIndex(0);
                        cbPomeriggio1.setEnabled(false);
                    }

                    //POMERIGGIO2
                    if (oraInizioEntryCorrente.equalsIgnoreCase(FASCIA_POMERIGGIO2_INIZIO)) {
                        entryPomeriggio2 = entry;
                        chiavistaPomeriggio2 = chiavista;
                        btCancellaTurnoPomeriggio2.setVisible(true);
                        btCancellaTurnoPomeriggio2.setBackground(COLOR_SELECTED);
                        btCancellaTurnoPomeriggio2.setText(PREFISSO_BOTTONE_CANCELLAZIONE_TURNO + chiavista.getName().trim());
                        //reset combobox chiavista associata
                        cbPomeriggio2.setSelectedIndex(0);
                        cbPomeriggio2.setEnabled(false);
                    }

                    //IMBRUNIRE
                    if (oraInizioEntryCorrente.equalsIgnoreCase(FASCIA_IMBRUNIRE_INIZIO)) {
                        entryImbrunire = entry;
                        chiavistaImbrunire = chiavista;
                        btCancellaTurnoImbrunire.setVisible(true);
                        btCancellaTurnoImbrunire.setBackground(COLOR_SELECTED);
                        btCancellaTurnoImbrunire.setText(PREFISSO_BOTTONE_CANCELLAZIONE_TURNO + chiavista.getName().trim());
                        //reset combobox chiavista associata
                        cbImbrunire.setSelectedIndex(0);
                        cbImbrunire.setEnabled(false);
                    }

                    //SERA
                    if (oraInizioEntryCorrente.equalsIgnoreCase(FASCIA_SERA_INIZIO)) {
                        entrySera = entry;
                        chiavistaSera = chiavista;
                        btCancellaTurnoSera.setVisible(true);
                        btCancellaTurnoSera.setBackground(COLOR_SELECTED);
                        btCancellaTurnoSera.setText(PREFISSO_BOTTONE_CANCELLAZIONE_TURNO + chiavista.getName().trim());
                        //reset combobox chiavista associata
                        cbSera.setSelectedIndex(0);
                        cbSera.setEnabled(false);
                    }


                } catch (Exception ex) {
                    ex.printStackTrace();
                }



            }

        }

        /*
        if (event != null) {
        btCancellaTurnoSera.setVisible(true);
        btCancellaTurnoSera.setText("Cancella "+event.getTitle().getPlainText().trim().replace(pattern, "").trim());

        System.out.println("Evento: "+event.getTitle().getPlainText());
        }
         */
    }

    private Calendario getChiavistaCorrente(String nomeChiavista) {
        for (int i = 0; i < chiavisti.size(); i++) {
            if (chiavisti.get(i).getName().equalsIgnoreCase(nomeChiavista)) {
                return chiavisti.get(i);
            }
        }
        return null;
    }

    private int checkNumberOfEvents (){
        //default 1, se però voglio sbombare allora li inserisco dal dialog
        int res =1;
        if (chkBomb.isSelected()) 
        {
            //non inserisco su master
            String resStr;
            res=Integer.parseInt( (resStr=JOptionPane.showInputDialog(this.getFrame(), "Quanti eventi/messaggi per sbombare qualcuno?", "Bomb Mode Enabled", JOptionPane.QUESTION_MESSAGE)) != null ? resStr : "0"   );

            //System.out.println(res);
        }
        return res;
        //return 0; //debug
    }

    private void invia(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_invia
        try {

            setStatus("Invio turni...");

            checkValidTurn();

            int eventiDaCreare = checkNumberOfEvents();            

            for (int i=0; i<eventiDaCreare; i++){

            setStatus("Creazione turni: [ "+(i+1)+" ]");

            //System.out.println("1");
            createEvents();

            }

            if ( eventiDaCreare!=0 )this.getChiavistiDelGiorno();

            //cbSelectGiornoItemStateChanged(new ItemEvent(null, null, null, 1));
            //ManageGoogleCalendar manage = new ManageGoogleCalendar();
            //CalendarService myService = manage.retrieveService(user, pwd);
            //manage.createEvent(myService, user, DateTime.parseDateTime("2011-10-07T09:30:00.000Z"), DateTime.parseDateTime("2011-10-07T12:30:00.000Z"));

            

        } catch (Exception ex) {
            //jTextArea1.setText(ex.getMessage());
            ex.printStackTrace();
            this.showErrorDialog(ex.getMessage());            
        }
    }//GEN-LAST:event_invia

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        try {
            resetInterface();
            popolateTurni();
            popolateNotificheRiunioni();
            updateDate();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this.getFrame(), e.getMessage(), "Errore", JOptionPane.ERROR_MESSAGE);
            lblStatus.setText("Errore: " + e.getMessage());
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void cbSelectGiornoRiunioneItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectGiornoRiunioneItemStateChanged
        changeLabelGiornoRiunioni();
    }//GEN-LAST:event_cbSelectGiornoRiunioneItemStateChanged

    private void cbSelectMeseRiunionecbSelectGiornoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectMeseRiunionecbSelectGiornoItemStateChanged
        changeLabelGiornoRiunioni();
    }//GEN-LAST:event_cbSelectMeseRiunionecbSelectGiornoItemStateChanged

    private void cbSelectAnnoRiunionecbSelectGiornoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSelectAnnoRiunionecbSelectGiornoItemStateChanged
        changeLabelGiornoRiunioni();
    }//GEN-LAST:event_cbSelectAnnoRiunionecbSelectGiornoItemStateChanged

    private void btCancellaTurnoMattinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancellaTurnoMattinaActionPerformed
        gestisciCancellazioneButton("MATTINA");
    }//GEN-LAST:event_btCancellaTurnoMattinaActionPerformed

    private void btCancellaTurnoPomeriggio1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancellaTurnoPomeriggio1ActionPerformed

        gestisciCancellazioneButton("POMERIGGIO1");

    }//GEN-LAST:event_btCancellaTurnoPomeriggio1ActionPerformed

    private void btCancellaTurnoPomeriggio2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancellaTurnoPomeriggio2ActionPerformed
        gestisciCancellazioneButton("POMERIGGIO2");
    }//GEN-LAST:event_btCancellaTurnoPomeriggio2ActionPerformed

    private void btCancellaTurnoImbrunireActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancellaTurnoImbrunireActionPerformed
        gestisciCancellazioneButton("IMBRUNIRE");
    }//GEN-LAST:event_btCancellaTurnoImbrunireActionPerformed

    private void btCancellaTurnoSeraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancellaTurnoSeraActionPerformed
        gestisciCancellazioneButton("SERA");
    }//GEN-LAST:event_btCancellaTurnoSeraActionPerformed

    private void gestisciCancellazioneButton(String fascia) {

        if (fascia.equalsIgnoreCase("MATTINA")) {
            try {
                if (entryMattina == null || chiavistaMattina == null) {
                    throw new Exception("Errore di dati! Non esiste il chiavista o l'entry dal calendario!");
                }

                //tolgo da calendario personale
                manage.deletePersonalEvent(myService, chiavistaMattina.getCalendar(), entryMattina);
                chiavistaMattina = null;
                //tolgo da calendario master
                entryMattina.delete();
                entryMattina = null;
                //resetInterface();

                this.btCancellaTurnoMattina.setBackground(COLOR_NOT_SELECTED);
                this.btCancellaTurnoMattina.setText(BOTTONE_CANCELLAZIONE);
                //enable combobox chiavista
                this.cbMattina.setEnabled(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


        if (fascia.equalsIgnoreCase("POMERIGGIO1")) {
            try {
                if (entryPomeriggio1 == null || chiavistaPomeriggio1 == null) {
                    throw new Exception("Errore di dati! Non esiste il chiavista o l'entry dal calendario!");
                }

                //tolgo da calendario personale
                manage.deletePersonalEvent(myService, chiavistaPomeriggio1.getCalendar(), entryPomeriggio1);
                chiavistaPomeriggio1 = null;
                //tolgo da calendario master
                entryPomeriggio1.delete();
                entryPomeriggio1 = null;
                //resetInterface();

                this.btCancellaTurnoPomeriggio1.setBackground(COLOR_NOT_SELECTED);
                this.btCancellaTurnoPomeriggio1.setText(BOTTONE_CANCELLAZIONE);
                //enable combobox chiavista
                this.cbPomeriggio1.setEnabled(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (fascia.equalsIgnoreCase("POMERIGGIO2")) {
            try {
                if (entryPomeriggio2 == null || chiavistaPomeriggio2 == null) {
                    throw new Exception("Errore di dati! Non esiste il chiavista o l'entry dal calendario!");
                }

                //tolgo da calendario personale
                manage.deletePersonalEvent(myService, chiavistaPomeriggio2.getCalendar(), entryPomeriggio2);
                chiavistaPomeriggio2 = null;
                //tolgo da calendario master
                entryPomeriggio2.delete();
                entryPomeriggio2 = null;
                //resetInterface();

                this.btCancellaTurnoPomeriggio2.setBackground(COLOR_NOT_SELECTED);
                this.btCancellaTurnoPomeriggio2.setText(BOTTONE_CANCELLAZIONE);
                //enable combobox chiavista
                this.cbPomeriggio2.setEnabled(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (fascia.equalsIgnoreCase("IMBRUNIRE")) {
            try {
                if (entryImbrunire == null || chiavistaImbrunire == null) {
                    throw new Exception("Errore di dati! Non esiste il chiavista o l'entry dal calendario!");
                }

                //tolgo da calendario personale
                manage.deletePersonalEvent(myService, chiavistaImbrunire.getCalendar(), entryImbrunire);
                chiavistaImbrunire = null;
                //tolgo da calendario master
                entryImbrunire.delete();
                entryImbrunire = null;
                //resetInterface();

                this.btCancellaTurnoImbrunire.setBackground(COLOR_NOT_SELECTED);
                this.btCancellaTurnoImbrunire.setText(BOTTONE_CANCELLAZIONE);
                //enable combobox chiavista
                this.cbImbrunire.setEnabled(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (fascia.equalsIgnoreCase("SERA")) {
            try {
                if (entrySera == null || chiavistaSera == null) {
                    throw new Exception("Errore di dati! Non esiste il chiavista o l'entry dal calendario!");
                }

                //tolgo da calendario personale
                manage.deletePersonalEvent(myService, chiavistaSera.getCalendar(), entryImbrunire);
                chiavistaSera = null;
                //tolgo da calendario master
                entrySera.delete();
                entrySera = null;
                //resetInterface();

                this.btCancellaTurnoSera.setBackground(COLOR_NOT_SELECTED);
                this.btCancellaTurnoSera.setText(BOTTONE_CANCELLAZIONE);
                //enable combobox chiavista
                this.cbSera.setEnabled(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

    private void changeLabelGiornoRiunioni() {
        int date = Integer.parseInt(this.cbSelectGiornoRiunione.getSelectedItem().toString());
        int month = cbSelectMeseRiunione.getSelectedIndex();
        int year = Integer.parseInt(this.cbSelectAnnoRiunione.getSelectedItem().toString());//;Integer.parseInt(.getItemAt(cbSelectAnno.getSelectedIndex()).toString());

        GregorianCalendar ogg = new GregorianCalendar(year, month, date);

        //console.setText(ogg.getTime().toString()+console.getText());
        //System.out.println("Questo giorno"+ogg.get(Calendar.DAY_OF_WEEK));
        int day = ogg.get(Calendar.DAY_OF_WEEK);
        //System.out.println("Day : "+day);
        String giorno = "";
        switch (day) {
            case 1:
                giorno = "Domenica";
                break;
            case 2:
                giorno = "Lunedì";
                break;
            case 3:
                giorno = "Martedi";
                break;
            case 4:
                giorno = "Mercoledì";
                break;
            case 5:
                giorno = "Giovedì";
                break;
            case 6:
                giorno = "Venerdì";
                break;
            case 7:
                giorno = "Sabato";
                break;
            default:
                giorno = "Non decodificato";
                break;
        }
        lblGiornoRiunione.setText(giorno);
    }

    private void checkValidTurn() throws Exception {

        if (!isSelected(cbMattina) && !isSelected(cbPomeriggio1) && !isSelected(cbPomeriggio2) && !isSelected(cbImbrunire) && !isSelected(cbSera)) {
            throw new Exception("Inserisci almeno un turno stordito!");
        }

        //se è sabato e non ho abilitato la checkbox per "abilita tutti" do errore se non sono compilati tutti e due i pomeriggi
        if (!chkAbilitaAll.isSelected() && jlGiorno.getText().equalsIgnoreCase("Sabato")) {
            if (!isSelected(cbPomeriggio1) || !isSelected(cbPomeriggio2)) {
                throw new Exception("Inserire il primo e il secondo turno del sabato!");
            }
        }

    }

    private void createEvents() throws Exception {

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();
        //CalendarService myService = manage.retrieveService(user, pwd);
        //if (true)throw new Exception("Test");

        //gestione eventi

        //System.out.println("2");

        String result = "Nessun evento creato.";

        String titleEventConst = TITLE_EVENT_TURNO;

        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String giorno = cbSelectGiorno.getSelectedItem().toString().trim();
        String mese = "" + (cbSelectMese.getSelectedIndex() + 1);
        String anno = cbSelectAnno.getSelectedItem().toString().trim();

        //Mattina 9.30-12.30
        if (isSelected(cbMattina)) {

            setStatus(getStatus()+" Mattina");
            //System.out.println("3");

            Calendario tempChiavista = (Calendario) cbMattina.getSelectedItem();
            String titleEvent = tempChiavista.getName() + " " + titleEventConst;
            String calendar = tempChiavista.getCalendar();

            //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
            Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_MATTINA_INIZIO + ":00");
            Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_MATTINA_FINE + ":00");
            String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
            String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
            ;
            DateTime startTime = DateTime.parseDateTime(dataInizioString);
            DateTime endTime = DateTime.parseDateTime(dataFineString);

            //System.out.println(titleEvent);
            //System.out.println(calendar);
            //System.out.println(startTime);
            //System.out.println(endTime);

            //inserisco su mastercalendar
            if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
            }
            //inserisco su calendario del chiavista
            result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);

            console.append("\r\n" + result);

            //throw new Exception(result);

        }


        //if (cbPomeriggio2.isEnabled())

        //Pomeriggio 18.30-20.30
        if (isSelected(cbPomeriggio1)) {
            if (!isSelected(cbPomeriggio2)) {

                //System.out.println("3");
                setStatus(getStatus()+" Pome1");
                Calendario tempChiavista = (Calendario) cbPomeriggio1.getSelectedItem();
                String titleEvent = tempChiavista.getName() + " " + titleEventConst;
                String calendar = tempChiavista.getCalendar();

                //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
                Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO1_INIZIO + ":00");
                Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO2_FINE + ":00");
                String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
                String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
                ;
                DateTime startTime = DateTime.parseDateTime(dataInizioString);
                DateTime endTime = DateTime.parseDateTime(dataFineString);

                //System.out.println(titleEvent);
                //System.out.println(calendar);
                //System.out.println(startTime);
                //System.out.println(endTime);

                //inserisco su mastercalendar
                if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                    result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
                }
                //inserisco su calendario del chiavista
                result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);

                console.append("\r\n" + result);

                //throw new Exception(result);

            } else {

                //System.out.println("3");

                setStatus(getStatus()+" Pome1");
                Calendario tempChiavista = (Calendario) cbPomeriggio1.getSelectedItem();
                String titleEvent = tempChiavista.getName() + " " + titleEventConst;
                String calendar = tempChiavista.getCalendar();

                //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
                Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO1_INIZIO + ":00");
                Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO1_FINE + ":00");
                String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
                String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
                ;
                DateTime startTime = DateTime.parseDateTime(dataInizioString);
                DateTime endTime = DateTime.parseDateTime(dataFineString);

                //System.out.println(titleEvent);
                //System.out.println(calendar);
                //System.out.println(startTime);
                //System.out.println(endTime);

                //inserisco su mastercalendar
                if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                    result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
                }
                //inserisco su calendario del chiavista
                result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);


                console.append("\r\n" + result);

                setStatus(getStatus()+" Pome2");
                tempChiavista = (Calendario) cbPomeriggio2.getSelectedItem();
                titleEvent = tempChiavista.getName() + " " + titleEventConst;
                calendar = tempChiavista.getCalendar();

                //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
                dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO2_INIZIO + ":00");
                dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_POMERIGGIO2_FINE + ":00");
                dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
                dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
                ;
                startTime = DateTime.parseDateTime(dataInizioString);
                endTime = DateTime.parseDateTime(dataFineString);

                //System.out.println(titleEvent);
                //System.out.println(calendar);
                //System.out.println(startTime);
                //System.out.println(endTime);

                //inserisco su mastercalendar
                if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                    result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
                }
                //inserisco su calendario del chiavista
                result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);

                console.append("\r\n" + result);

                //throw new Exception(result);
            }
        }


        //Imbrunire 18.30-20.30
        if (isSelected(cbImbrunire)) {

            //System.out.println("3");

            setStatus(getStatus()+" Imbrunire");

            Calendario tempChiavista = (Calendario) cbImbrunire.getSelectedItem();
            String titleEvent = tempChiavista.getName() + " " + titleEventConst;
            String calendar = tempChiavista.getCalendar();

            //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
            Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_IMBRUNIRE_INIZIO + ":00");
            Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_IMBRUNIRE_FINE + ":00");
            String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
            String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
            ;
            DateTime startTime = DateTime.parseDateTime(dataInizioString);
            DateTime endTime = DateTime.parseDateTime(dataFineString);

            //System.out.println(titleEvent);
            //System.out.println(calendar);
            //System.out.println(startTime);
            //System.out.println(endTime);

            //inserisco su mastercalendar
            if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
            }
            //inserisco su calendario del chiavista
            result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);

            console.append("\r\n" + result);

            //throw new Exception(result);

        }

        //Sera 20.30-23.00
        if (isSelected(cbSera)) {

            //System.out.println("3");

            setStatus(getStatus()+" Sera.");

            Calendario tempChiavista = (Calendario) cbSera.getSelectedItem();
            String titleEvent = tempChiavista.getName() + " " + titleEventConst;
            String calendar = tempChiavista.getCalendar();

            //dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
            Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_SERA_INIZIO + ":00");
            Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + FASCIA_SERA_FINE + ":00");
            String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
            String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
            ;
            DateTime startTime = DateTime.parseDateTime(dataInizioString);
            DateTime endTime = DateTime.parseDateTime(dataFineString);

            //System.out.println(titleEvent);
            //System.out.println(calendar);
            //System.out.println(startTime);
            //System.out.println(endTime);

            //inserisco su mastercalendar
            if (chkInserimentoMaster.isSelected() && !chkBomb.isSelected()) {
                result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, "", startTime, endTime);
            }
            //inserisco su calendario del chiavista
            result = manage.createEvent(myService, calendar, titleEvent, "", startTime, endTime);

            console.append("\r\n" + result);

            //throw new Exception(result);

        }

    }

    private boolean isSelected(JComboBox cb) {
        return !cb.getSelectedItem().toString().trim().equalsIgnoreCase("Not Selected");
    }

    @Action
    public void creaChiavista() {
        try {
            setStatus("Creazione calendar-chiavista..");
            checkFieldsCreaChiavista();
            creaCalendarChiavista();
            //resetInterface();
            //popolateTurni();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this.getFrame(), e.getMessage(), "Errore", JOptionPane.ERROR_MESSAGE);
            lblStatus.setText("Errore: " + e.getMessage());
        }
    }

    private void checkFieldsCreaChiavista() throws Exception {
        if (this.txtChiavista.getText() == null || this.txtChiavista.getText().trim().equalsIgnoreCase("Turni -")) {
            throw new Exception("Inserire il nome del chiavista");
        }
    }

    private void creaCalendarChiavista() throws AuthenticationException, IOException, ServiceException {
        String nomeCalendario = this.txtChiavista.getText().trim();
        String descCalendario = this.txtChiavista.getText().trim();

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();
        //CalendarService myService = manage.retrieveService(user, pwd);


        String result = manage.createNewCalendarChiavista(myService, OWN_CALENDARS, nomeCalendario, descCalendario);

        lblStatus.setText(result);

    }

    @Action
    public void deleteCalendarChiavista() {
        try {
            setStatus("Cancellazione calendar-chiavista..");
            checkFieldsCreaChiavista();
            cancellaCalendarChiavista();
            //resetInterface();
            //popolateTurni();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this.getFrame(), e.getMessage(), "Errore", JOptionPane.ERROR_MESSAGE);
            lblStatus.setText("Errore: " + e.getMessage());
        }

    }

    private void cancellaCalendarChiavista() throws AuthenticationException, MalformedURLException, IOException, ServiceException {

        String nomeCalendario = this.txtChiavista.getText().trim();

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();
        //CalendarService myService = manage.retrieveService(user, pwd);


        String result = manage.deleteCalendar(myService, OWN_CALENDARS, nomeCalendario);

        lblStatus.setText(result);
    }

    @Action
    public void creaRiunione() {
        try {
            setStatus("Creazione evento riunione..");
            checkFieldsRiunione();
            createRiunione();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this.getFrame(), e.getMessage(), "Errore", JOptionPane.ERROR_MESSAGE);
            lblStatus.setText("Errore: " + e.getMessage());
        }
    }

    private void checkFieldsRiunione() throws Exception {
        if (this.cbRiunioni.getSelectedItem().toString().equalsIgnoreCase("Not selected") || this.txtOraInizioEvento.getText() == null || this.txtOraFineEvento.getText() == null || this.txtTitoloEvento == null) {
            throw new Exception("Inserire tutti i dati!");
        }
    }

    private void createRiunione() throws AuthenticationException, ParseException, IOException, ServiceException {

        //ManageGoogleCalendar manage = new ManageGoogleCalendar();

        //CalendarService myService = manage.retrieveService(user, pwd);

        String result = "Nessun evento creato.";

        Calendario tempCalendario = (Calendario) cbRiunioni.getSelectedItem();
        String calendar = tempCalendario.getCalendar();

        String titleEvent = txtTitoloEvento.getText().trim();
        String descEvent = txtDescrizioneEvento.getText().trim();



        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String giorno = cbSelectGiornoRiunione.getSelectedItem().toString().trim();
        String mese = "" + (cbSelectMeseRiunione.getSelectedIndex() + 1);
        String anno = cbSelectAnnoRiunione.getSelectedItem().toString().trim();
        String oraInizio = txtOraInizioEvento.getText().trim();
        String oraFine = txtOraFineEvento.getText().trim();


        Date dataInizio = dfm.parse(anno + "-" + mese + "-" + giorno + " " + oraInizio + ":00");
        Date dataFine = dfm.parse(anno + "-" + mese + "-" + giorno + " " + oraFine + ":00");
        String dataInizioString = (dfm.format(dataInizio) + offsetUTC).replace(' ', 'T');
        String dataFineString = (dfm.format(dataFine) + offsetUTC).replace(' ', 'T');
        ;
        DateTime startTime = DateTime.parseDateTime(dataInizioString);
        DateTime endTime = DateTime.parseDateTime(dataFineString);

        //System.out.println(titleEvent);
        //System.out.println(calendar);
        //System.out.println(startTime);
        //System.out.println(endTime);

        //inserisco su mastercalendar
        result = manage.createEvent(myService, POST_URL_MASTER_CALENDAR, titleEvent, descEvent, startTime, endTime);

        //inserisco su calendario delle notifiche
        result = manage.createEvent(myService, calendar, titleEvent, descEvent, startTime, endTime);

        lblStatus.setText(result);

        //throw new Exception(result);


    }

    private void setLogo(){
        // Set Icona Applicazione
        Image img = null;
        try{
        URL url = ClassLoader.getSystemResource("googlecalendarmanagerevo/resources/logo.png");
        Toolkit kit = Toolkit.getDefaultToolkit();
        img = kit.createImage(url);
        this.getFrame().setIconImage(img);
        }
        catch(Exception e){
            e.printStackTrace();
            //vado avanti e non blocco l'app
        }
    }

    public void setAutoconnection(boolean b){
        autoconnection=b;
    }

    public boolean getAutoconnection(){
        return autoconnection;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancellaTurnoImbrunire;
    private javax.swing.JButton btCancellaTurnoMattina;
    private javax.swing.JButton btCancellaTurnoPomeriggio1;
    private javax.swing.JButton btCancellaTurnoPomeriggio2;
    private javax.swing.JButton btCancellaTurnoSera;
    private javax.swing.JButton buttonCancellaChiavista;
    private javax.swing.JButton buttonCreaChiavista;
    private javax.swing.JButton buttonMinusDay;
    private javax.swing.JButton buttonPlusDay;
    private javax.swing.JComboBox cbImbrunire;
    private javax.swing.JComboBox cbMattina;
    private javax.swing.JComboBox cbPomeriggio1;
    private javax.swing.JComboBox cbPomeriggio2;
    private javax.swing.JComboBox cbRiunioni;
    private javax.swing.JComboBox cbSelectAnno;
    private javax.swing.JComboBox cbSelectAnnoRiunione;
    private javax.swing.JComboBox cbSelectGiorno;
    private javax.swing.JComboBox cbSelectGiornoRiunione;
    private javax.swing.JComboBox cbSelectMese;
    private javax.swing.JComboBox cbSelectMeseRiunione;
    private javax.swing.JComboBox cbSera;
    private javax.swing.JCheckBox chkAbilitaAll;
    private javax.swing.JCheckBox chkBomb;
    private javax.swing.JCheckBox chkInserimentoMaster;
    private javax.swing.JTextArea console;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonCreaEvento;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenu jMenuTools;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel jlGiorno;
    private javax.swing.JLabel lblGiornoRiunione;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextField txtChiavista;
    private javax.swing.JTextArea txtDescrizioneEvento;
    private javax.swing.JTextField txtOraFineEvento;
    private javax.swing.JTextField txtOraInizioEvento;
    private javax.swing.JTextField txtTitoloEvento;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    private JDialog optionsDialog;
    private JDialog loginDialog;


}
